var int = document.querySelector(".as > input");
var a = document.querySelector(".right ul");
var b = document.querySelector(".right1 ul");
var right1 = document.querySelectorAll(".right");
var act = document.querySelectorAll(".left ul li");
var z = [];
var x = [];
var c = [];
var v = [];
var s = [];
int.onkeydown = function(e){
    var ev = document.all ? window.event : e;
    if(ev.keyCode==13){
        if(int.value != ""){
            var date = new Date;
            var year = date.getFullYear();
            var month=date.getMonth()+1;
            month =(month<10 ? "0"+month:month);
            var day = date.getDate();
            var hours = date.getHours(); //时
            var minutes = date.getMinutes(); //分
            var seconds = date.getSeconds(); //秒
            var li1 = document.createElement("LI");
            var div1 = document.createElement("DIV");
            var div2 = document.createElement("DIV");
            var i1 = document.createElement('INPUT');
            var label1 = document.createElement("LABEL");
            var i2 = document.createElement('I');
            var input1 = document.createElement('INPUT');
            var div3 = document.createElement('DIV');
            var span1 = document.createElement('SPAN');
            //添加事项
            a.appendChild(li1);
            li1.appendChild(div1);
            div1.appendChild(div2);
            div2.appendChild(i1);
            div2.className = "yuan";
            i1.type = 'checkbox';
            i1.name = 'btn';
            i1.id = 'btn1';
            i1.appendChild(label1);
            var pp = i1.checked;
            label1.for = 'btn1';
            div1.appendChild(input1);
            input1.value = int.value;
            li1.appendChild(div3);
            div3.appendChild(span1);
            span1.innerHTML = year+'/'+month+'/'+day+'&nbsp'+hours+':'+minutes+':'+seconds;
            div3.appendChild(i2);
            i1.className = 'far fa-circle';
            i2.className = 'far fa-trash-alt';
            int.value = "";
            z.push(i2);
            x.push(li1);
            c.push(i1);
            v.push(input1);
            s.push(span1);
            //删除事项
            for (var i = 0;i< z.length;i++){
                z[i].index = i;
                z[i].addEventListener('click',function(){
                    x[this.index].style.display = 'none';
                });
            }
            //标记事项
            for (var j = 0;j< c.length;j++){
                c[j].index = j;
                c[j].addEventListener("click",function(){
                    if (c[this.index].checked != false){
                        v[this.index].classList.add('line-through');
                        var div4 = document.createElement("DIV");
                        b.appendChild(div4);
                        var date1 = new Date;
                        var year1 = date1.getFullYear();
                        var month1=date1.getMonth()+1;
                        month1 =(month<10 ? "0"+month:month);
                        var day1 = date1.getDate();
                        var hours1 = date1.getHours(); //时
                        var minutes1 = date1.getMinutes(); //分
                        var seconds1 = date1.getSeconds(); //秒
                        s[this.index].innerHTML = "完成于："+year1+'/'+month1+'/'+day1+'&nbsp'+hours1+':'+minutes1+':'+seconds1;
                        b.appendChild(x[this.index]);
                    }else {
                        v[this.index].classList.remove('line-through');
                        var date2 = new Date;
                        var year2 = date2.getFullYear();
                        var month2=date2.getMonth()+1;
                        month1 =(month<10 ? "0"+month:month);
                        var day2 = date2.getDate();
                        var hours2 = date2.getHours(); //时
                        var minutes2 = date2.getMinutes(); //分
                        var seconds2 = date2.getSeconds(); //秒
                        s[this.index].innerHTML = year2+'/'+month2+'/'+day2+'&nbsp'+hours2+':'+minutes2+':'+seconds2;
                        a.appendChild(x[this.index]);
                    }
                });
            }
        }
    }
};
for (var m = 0;m<act.length;m++){
    act[m].index = m;
    act[m].addEventListener('click',function(){
        for(var n = 0;n<act.length;n++){
            act[n].classList.remove('active');
            right1[n].classList.add('hidder');
        }
        this.classList.add('active');
        right1[this.index].classList.remove('hidder');
    })
}